package org.br.plotter.functions;

import org.br.plotter.parser.*;

public abstract class Function {
	public static Function parseFunction(String func) throws ParseException {
		java.io.ByteArrayInputStream bis = new java.io.ByteArrayInputStream(
				func.getBytes());
		FunctionParser fp = new FunctionParser(bis);
		return fp.operationalFunction();
	}

	public abstract double eval(double x);

	public static void main(String[] args) throws Exception {
		String equation = "4*x^3 + 5";
		Function f = parseFunction(equation);
		System.out.println(f.eval(2));
	}
}